package org.dei.perla.utils;


public abstract class Notifier {

	private boolean allFlag;
	private ObserverInterface observer;
		
	public synchronized boolean isTheTurnOf(ObserverInterface observer){
		if(allFlag)
			return true;
		return observer.equals(this.observer);
	}
	
	public void notifyAllObserver() {
		synchronized (this) {
			this.allFlag = true;
			this.notifyAll();
		}
	}
	
	public void notifyObserver(ObserverInterface observer){
		synchronized (this) {
			this.allFlag = false;
			this.observer = observer;
			this.notifyAll();
		}
	}
	
}
